package Network;

import java.util.Calendar;

/**
   Copyright (C) 2009 BBC Research, Sam Davies, <Sam.Davies@bbc.co.uk>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.


 */
public class UbiSenseCoords {

    private double x,  y,  z;
    private String name;
    private String time;
    private String type;
    private double h,  m,  s,  ms,  intTime;
    private int wait = 1000;

    public UbiSenseCoords(double x, double y, double z, String name, String time, String type) {
        this.x = x;
        this.y = y;
        this.z = z;
        this.name = name;
        this.time = time;
        this.type = type;
        Calendar cal = Calendar.getInstance();
        this.h = cal.get(Calendar.HOUR);
        this.m = cal.get(Calendar.MINUTE);
        this.s = cal.get(Calendar.SECOND);
        this.ms = cal.get(Calendar.MILLISECOND);
        this.intTime = cal.getTimeInMillis();

    }

    public UbiSenseCoords(double x, double y, double z, String name, double h, double m, double s, double ms, String type) {
        this.x = x;
        this.y = y;
        this.z = z;
        this.name = name;
        Calendar cal = Calendar.getInstance();
        this.h = cal.get(Calendar.HOUR);
        this.m = cal.get(Calendar.MINUTE);
        this.s = cal.get(Calendar.SECOND);
        this.ms = cal.get(Calendar.MILLISECOND);
        this.intTime = cal.getTimeInMillis();

    }

    public UbiSenseCoords(double x, double y, double z, String name, String type) {
        this.x = x;
        this.y = y;
        this.z = z;
        this.name = name;
        this.type = type;
        Calendar cal = Calendar.getInstance();
        this.h = cal.get(Calendar.HOUR);
        this.m = cal.get(Calendar.MINUTE);
        this.s = cal.get(Calendar.SECOND);
        this.ms = cal.get(Calendar.MILLISECOND);
        this.time = h + ":" + m + ":" + s + ";" + ms;
        this.intTime = cal.getTimeInMillis();

    }

    public UbiSenseCoords(double x, double y, double z, String name, double h, double m, double s, String type) {
        this.x = x;
        this.y = y;
        this.z = z;
        this.name = name;
        this.type = type;
        Calendar cal = Calendar.getInstance();
        this.h = cal.get(Calendar.HOUR);
        this.m = cal.get(Calendar.MINUTE);
        this.s = cal.get(Calendar.SECOND);
        this.ms = cal.get(Calendar.MILLISECOND);
        this.intTime = cal.getTimeInMillis();
    }

    public UbiSenseCoords(double x, double y, double z, String name, double h, double m, double s, String type, int wait) {
        this.x = x;
        this.y = y;
        this.z = z;
        this.name = name;
        this.m = m;
        this.h = h;
        this.s = s;
        this.type = type;
        this.ms = 0;
        this.time = h + ":" + m + ":" + s + ";" + ms;
        this.wait = wait;
    }

    /**
     * @return the x
     */
    public double getX() {
        return x;
    }

    public void setH(long h) {
        this.h = h;
    }

    public void setM(long m) {
        this.m = m;
    }

    public void setS(long s) {
        this.s = s;
    }

    /**
     * @param x the x to set
     */
    public void setX(double x) {
        this.x = x;
    }

    /**
     * @return the y
     */
    public double getY() {
        return y;
    }

    /**
     * @param y the y to set
     */
    public void setY(double y) {
        this.y = y;
    }

    /**
     * @return the z
     */
    public double getZ() {
        return z;
    }

    /**
     * @param z the z to set
     */
    public void setZ(double z) {
        this.z = z;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the time
     */
    public String getTime() {
        return time;
    }

    /**
     * @param time the time to set
     */
    public void setTime(String time) {
        this.time = time;
    }

    /**
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * @return the h
     */
    public double getH() {
        return h;
    }

    /**
     * @return the m
     */
    public double getM() {
        return m;
    }

    /**
     * @return the s
     */
    public double getS() {
        return s;
    }

    /**
     * @return the ms
     */
    public double getMs() {
        return ms;
    }

    public void setTime(double h, double m, double s, double ms) {
        this.h = h;
        this.m = m;
        this.s = s;
        this.ms = ms;
    }

    public void setMS(double msNew) {
        ms = msNew;
    }

    public String getIntTimesAsString() {
        return (int) h + ";" + (int) m + ";" + (int) s + ":" + (int) ms;
    }

    public String computerFriendly() {
        return this.name + "," + this.type + "," + this.x + "," + this.y + "," + this.z + "," + this.getIntTimesAsString() + "," + this.wait;
    }

    public double getIntTime() {
        return intTime;
    }

    public void setIntTime(double intTime) {
        this.intTime = intTime;
    }

    /**
     * @return the wait
     */
    public int getWait() {
        return wait;
    }

    /**
     * @param wait the wait to set
     */
    public void setWait(int wait) {
        this.wait = wait;
    }
}
